package com.CampaignManager.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.google.gwt.maps.client.geom.LatLng;

@SuppressWarnings("serial")
public class CityDTO implements Serializable {
	
	private Long cityId;
	private String name;
	private double latitude;
	private double longitude;
	private String faction;
	
	private List<ResourceAmountDTO> relations;	
	public List<ResourceAmountDTO> getRelations() {
		if (relations == null) relations = new ArrayList<ResourceAmountDTO>();
		return relations;
	}
	public ResourceAmountDTO getRelation(String otherCity) {
		ResourceAmountDTO rel = null;
		for (ResourceAmountDTO pc : this.getRelations()) {
			if (pc.getResource().equalsIgnoreCase(otherCity)) {
				rel = pc;
			}
		}
		if (rel == null) {
			rel = new ResourceAmountDTO();
			rel.setResource(otherCity);
			rel.setAmount(0L);
			this.getRelations().add(rel);
		}
		return rel;
	}
	
	public Long getCityId() {
		return cityId;
	}
	public void setCityId(Long cityId) {
		this.cityId = cityId;
	}		
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public double getLatitude() {
		return latitude;
	}
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}
	public double getLongitude() {
		return longitude;
	}
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}
	public String getFaction() {
		return faction;
	}
	public void setFaction(String faction) {
		this.faction = faction;
	}
	
	public LatLng GetLocation() {
		return LatLng.newInstance(this.getLatitude(), this.getLongitude());
	}
	
	public static String[] getAllResources() {
		
		List<String> resources = new ArrayList<String>();
		resources.add("Food");
		resources.add("Coal");
		resources.add("Water");
		resources.add("Hay");
		resources.add("Arcane");
		resources.add("Gold");
		resources.add("Blasting Powder");
		resources.add("Wool Cloth");
		resources.add("GunPowder");

		return (String[]) resources.toArray(new String[0]);
	}
}
